home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ada
/
gnat1792.zip
/
gnat179b
/
t-adainc
/
s-taruty.ads
< prev
next >
Wrap
Text File
|
1994-05-19
|
18KB
|
407 lines
------------------------------------------------------------------------------
-- --
-- GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . R U N T Y P E _ T Y P E S --
-- --
-- S p e c --
-- --
-- $Revision: 1.6 $ --
-- --
-- Copyright (c) 1991,1992,1993, FSU, All Rights Reserved --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU Library General Public License as published by the --
-- Free Software Foundation; either version 2, or (at your option) any --
-- later version. GNARL is distributed in the hope that it will be use- --
-- ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Gen- --
-- eral Library Public License for more details. You should have received --
-- a copy of the GNU Library General Public License along with GNARL; see --
-- file COPYING. If not, write to the Free Software Foundation, 675 Mass --
-- Ave, Cambridge, MA 02139, USA. --
-- --
------------------------------------------------------------------------------
with Unchecked_Conversion;
package System.Tasking.Runtime_Types is
-- Entry queue related types
type Server_Kind is (Task_Server, PO_Server);
type Server_Record (Kind : Server_Kind := Task_Server) is record
case Kind is
when Task_Server =>
Called_Task : Task_ID;
Acceptor_Prev_Call : Entry_Call_Link;
Acceptor_Prev_Priority : Rendezvous_Priority;
-- For a task servicing a task entry call,
-- information about the most recent prior call being serviced.
-- Not used for protected entry calls;
-- this function should be performed by GNULLI ceiling locking.
when PO_Server =>
Called_PO : Protection_Access;
end case;
end record;
-- Protected Objects related definitions
Null_PO : constant Protection_Access := null;
-- ATCB type defintions
type Ada_Task_Control_Block (Entry_Num : Task_Entry_Index);
type ATCB_Ptr is access Ada_Task_Control_Block;
All_Tasks_List : ATCB_Ptr;
All_Tasks_L : Task_Primitives.Lock;
function ID_To_ATCB is new
Unchecked_Conversion (Task_ID, ATCB_Ptr);
function ATCB_To_ID is new
Unchecked_Conversion (ATCB_Ptr, Task_ID);
function ATCB_To_Address is new
Unchecked_Conversion (ATCB_Ptr, System.Address);
type Task_Stage is (
Created,
-- Task has been created but has not begun activation.
Can_Activate,
-- Task has begin activation.
Active,
-- Task has completed activation and is executing the task body.
Await_Dependents,
-- Task is waiting for all of its dependents to become passive (be
-- complete, terminated, or be waiting on a terminate alternative).
Passive,
-- The task is passive.
Completing,
-- The task is committed to becoming complete, but has not yet
-- satisfied all of the conditions for completion. This
-- acts as a claim to completion; once Stage is set to this value,
-- no other task can continue with completion.
Complete,
-- The task is complete. The task and all of its dependents are
-- passive; some dependents may still be waiting on terminate
-- alternatives.
Terminated);
-- The task is terminated. All dependents waiting on terminate
-- alternatives have been awakened and have terminated themselves.
type Accepting_State is (
Not_Accepting, -- task is not ready to accept any entry call
Trivial_Accept, -- "accept E;"
Simple_Accept, -- "accept E do ... end E;"
Select_Wait); -- most general case
type Entry_Call_Array is array (ATC_Level_Index) of
aliased Entry_Call_Record;
type Entry_Queue_Array is array (Task_Entry_Index range <>) of Entry_Queue;
-- Notes on protection (synchronization) of TRTS data structures.
-- Any field of the TCB can be written by the activator of a task when the
-- task is created, since no other task can access the new task's
-- state until creation is complete.
-- The protection for each field is described in a comment starting with
-- "Protection:".
-- When a lock is used to protect an ATCB field, this lock is simply named.
-- Some protection is described in terms of tasks related to the
-- ATCB being protected. These are:
-- Self: The task which is controlled by this ATCB.
-- Acceptor: A task accepting a call from Self.
-- Caller: A task calling an entry of Self.
-- Parent: The task executing the master on which Self depends.
-- Dependent: A task dependent on Self.
-- Activator: The task that created Self and initiated its activation.
-- Created: A task created and activated by Self.
type Ada_Task_Control_Block (Entry_Num : Task_Entry_Index) is record
LL_TCB : aliased Task_Primitives.Task_Control_Block;
-- Control block used by the underlying low-level tasking service
-- (GNULLI).
-- Protection: This is used only by the GNULLI implementation, which
-- takes care of all of its synchronization.
Task_Entry_Point : Init_State;
-- Information needed to call the procedure containing the code for
-- the body of this task.
-- Protection: Part of the synchronization between Self and
-- Activator. Activator writes it, once, before Self starts
-- executing. Self reads it, once, as part of its execution.
Task_Arg : System.Address;
-- The argument to to task procedure. Currently unused; this will
-- provide a handle for discriminant information.
-- Protection: Part of the synchronization between Self and
-- Activator. Activator writes it, once, before Self starts
-- executing. Thereafter, Self only reads it.
Stack_Size : Size_Type;
-- Requested stack size.
-- Protection: Only used by Self.
Current_Priority : System.Priority;
-- Active priority, except that the effects of protected object
-- priority ceilings are not reflected. This only reflects explicit
-- priority changes and priority inherited through task activation
-- and rendezvous.
-- Ada 9X notes: In Ada 9X, this field will be transferred to the
-- Priority field of an Entry_Calls componant when an entry call
-- is initiated. The Priority of the Entry_Calls componant will not
-- change for the duration of the call. The accepting task can
-- use it to boost its own priority without fear of its changing in
-- the meantime.
-- This can safely be used in the priority ordering
-- of entry queues. Once a call is queued, its priority does not
-- change.
-- Since an entry call cannot be made while executing
-- a protected action, the priority of a task will never reflect a
-- priority ceiling change at the point of an entry call.
-- Protection: Only written by Self, and only accessed when Acceptor
-- accepts an entry or when Created activates, at which points Self is
-- suspended.
L : Task_Primitives.Lock;
-- General purpose lock; protects most fields in the ATCB.
Compiler_Data :